<!-- 信息组件 -->
<template>
	<div>
		<img :src="require('@/assets/images/yajiejieLogo.png')" class="author-img" alt="author avatar">
		<h1 class="author-tit">彦彦家的肥菇凉</h1>
		<div class="author-des">彦彦和彦彦家的肥菇凉</div>
		<div class="author-stat">
			<a class="item" href="#/archive/">
				<p>{{dataLeng.length}}</p>
				<div>文章</div>
			</a>
			<a class="item" href="#/Classify">
				<p>{{classifyLeng.length}}</p>
				<div>分类</div>
			</a>
			<a class="item" href="#/Label">
				<p>{{tagsLeng.length}}</p>
				<div>标签</div>
			</a>
		</div>
		<div class="author-link">
			<span v-for="(item,index) in linkList" :key="index">
				<a target="view_window" class="item" :href="item.herfLink">
					<svg class="icon" aria-hidden="true">
						<use :xlink:href="item.iconLink"></use>
					</svg>
				</a>
			</span>
		</div>
	</div>
</template>

<script>
	import {} from '../../assets/font/iconfont.js'
	export default {
		name: 'MyInfo',
		data() {
			return {
				dataLeng: [],
				tagsLeng: [],
				classifyLeng: [],
				linkList:[]
			}
		},
		mounted() {
			this.getBlogpost();
			this.getBlogsExtLink();
		},
		methods:{
			getBlogpost(){
				this.$axios.post(this.HOST + '/api/indexPage').then(res => {
					let data = res.data.data;
					this.dataLeng = data
					let map1 = {};
					let map2 = {};
					for (let i=0; i<data.length;i++) {
						if (!map1[data[i].tags]) {
							this.tagsLeng.push({
								tags: data[i].tags
							});
							map1[data[i].tags] = data[i]
						}
						if (!map2[data[i].classify]) {
							this.classifyLeng.push({
								classify: data[i].classify
							});
							map2[data[i].classify] = data[i]
						}
					}
				}).catch(err => {
					console.log(err, ' catch ')
				})
			},
			getBlogsExtLink(){
				this.$axios.post(this.HOST + '/api/blogExtLink').then(res => {
					let data = res.data.data;
					for (let i=0; i<data.length;i++) {
						if (data[i].typeLink == 'infoLink') {
							this.linkList.push(data[i])
						}
					}
				}).catch(err => {
					console.log(err, ' catch ')
				})
			}
		}
	}
</script>

<style>

</style>
